import Cookies from 'js-cookie'

const TokenKey = 'ruifox_admin_token'
const routerKey = 'ruifox_user_router'
const menuKey = 'ruifox_user_menu'
const userInfoKey = 'ruifox_user_info'
export function getToken() {
    return Cookies.get(TokenKey)
}

export function setToken(token) {
    return Cookies.set(TokenKey, token)
}

export function removeToken() {
    return Cookies.remove(TokenKey)
}

export function setRouter(routes) {
    routes = JSON.stringify(routes)
    return localStorage.setItem(routerKey, routes)
}

export function getRouter() {
    return JSON.parse(localStorage.getItem(routerKey))
}
export function setMenus(menus) {
    menus = JSON.stringify(menus)
    return localStorage.setItem(menuKey, menus)
}

export function getMenus() {
    return JSON.parse(localStorage.getItem(menuKey))
}

export function removeMenus() {
    return localStorage.removeItem(menuKey)
}

export function removeRouter() {
    return localStorage.removeItem(routerKey)
}
export function setLoginState(state) {
    return Cookies.set('ruifox_loginState',state)
}
export function getLoginState() {
    return Cookies.get('ruifox_loginState')
}
export function setUserInfo(info) {
    info = JSON.stringify(info)
    return localStorage.setItem(userInfoKey, info)
}
export function getUserInfo() {
    return JSON.parse(localStorage.getItem(userInfoKey))
}
export function setSiteInfo(info) {
    info = JSON.stringify(info)
    return localStorage.setItem('site_info',info)
}
export function getSiteInfo() {
    return JSON.parse(localStorage.getItem('site_info'))
}
export function setRefreshToken(token) {
    return localStorage.setItem('ruifox_refresh_token',token)
}
export function getRefreshToken() {
    return localStorage.getItem('ruifox_refresh_token')
}
export function setThemeColor(themeColor) {
    return localStorage.setItem('ruifox_admin_theme',themeColor)
}
export function getThemeColor() {
    return localStorage.getItem('ruifox_admin_theme')
}
export function setOperatorData(data) {
    data = JSON.stringify(data)
    return localStorage.setItem('ruifox_operator_data', data)
}
export function getOperatorData() {
    return JSON.parse(localStorage.getItem('ruifox_operator_data'))
}
export function setOperatorMapping(mapping) {
    mapping = JSON.stringify(mapping)
    return localStorage.setItem('ruifox_operator_mapping', mapping)
}
export function getOperatorMapping() {
    return JSON.parse(localStorage.getItem('ruifox_operator_mapping'))
}